Making Conversation possible to create directly a full conversation#9434
Making Conversation possible to create directly a full conversation#9434
Conversation
fully created from static state.
|
That's really cool! Also pinging @guillaume-be here as he might is the original author of the pipeline :-) |
+ remove dead enumerate + improve warning message.
| history.extend(new_history) | ||
| conversation._index = i + index + 1 | ||
| conversation._history = history | ||
| return history[:] |
There was a problem hiding this comment.
| return history[:] | |
| return history |
There was a problem hiding this comment.
Same here, and even more important, don't pass back a reference to users to cached values. They can do whatever they want with the copy, if it's a reference then they might mess it up:
history = conversation._get_history()
history.append("a") # Now conversation._history also contains "a" if I'm not mistaken
tests/test_pipelines_common.py
Outdated
| self.assertRaises(Exception, nlp, self.invalid_inputs) | ||
|
|
||
|
|
||
| class DummyTok: |
There was a problem hiding this comment.
This class uses torch so it should probably be inside an if is_torch_available() block.
Edit: Looks fine in the tests as long as we don't instantiate it without torch present so feel free to ignore this comment.
There was a problem hiding this comment.
I will ignore for the time being. I think this might change anyway linked to this discussion: #9432 (comment)
|
|
||
| @require_torch | ||
| def test_integration_torch_conversation(self): | ||
| nlp = self.get_pipeline() |
There was a problem hiding this comment.
Please, let's all stop naming a pipeline with a generic nlp. It's not the whole field of nlp, but a conversional agent, so conversational_agent or something in the same vein/shorter would be better here :-)
There was a problem hiding this comment.
I'm all up for it ! Do you mind if we keep this for a separate PR ?
nlp = pipeline is used pretty much everywhere in tests, I don't want to break uniformity here.
There was a problem hiding this comment.
I don't mind, but I'd really like this done. Let me know if you don't plan to tackle it soon and I'll make a good first issue out of it.
There was a problem hiding this comment.
Let's do a good first issue, It seems to really be a big replace but it's always nice to have those kind of issues for newcomers, right ?
There was a problem hiding this comment.
I agree with @sgugger here. Also I think it's no problem to break "naming" unity in the tests as long as the new name is better. It's easier to do a good first issue if one has this name as a reference of how it should be done IMO
There was a problem hiding this comment.
Perfect. I'll change the name here and create First issue, feel free to edit afterwards.
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
|
Also, @Narsil do you if it's possible to have a chat not widget in the inference API for this pipeline? I think it would be really nice to place around Blenderbot and DialoGPT |
@patrickvonplaten it's in the pipes, but I've not yet created the widget for huggingface.co, the @patrickvonplaten, @sgugger can you please re-review. There sort of major bug, where we used
Ping @mfuntowicz to make sure we can safely remove that or if there was a strong reason for bypassing tokenizer logic there. |
|
Also changed the tokenizer behavior to use a real one. |
|
Thanks for looping me in! It looks like there are a lot of changes, a few comments on my side:
to: are you sure that the behaviour remains correct for DialoGPT? As far as I know DialoGPT uses the GPT2 tokenizer that does not add a
Thanks! |
|
Hi @guillaume-be , Those changes do not belong in this PR anyway, I'll make a separate PR following this one, we should continue the discussion over there. |
|
It seems the tests are failing in |
|
Yes, was missing a rebase before test, another commit introduced a new warning, which broke the test. I am not sure what's the strategy concerning warnings and tests. I've tried to be conservative (meaning explicitly testing them), but I know it might become cumbersome at some point, I can remove those checks if needed. |
What does this PR do?
conversation.historynamely).historyis not correctlyupdated by the Conversation object.
Objectives of this PR:
Conversation("Why do you recommend it ?", past_user_inputs=["Can you recommend a book ?"], generated_responses=["I recommend reading the Lord of the Rings."])historyrenamed_history+_indexas it's now treated as a cache variable (namely to prevent recreating tokens of the conversation all the time.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@mfuntowicz
@sgugger
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors which may be interested in your PR.